﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using mscook.core;
using mscook.core.components;
using mscook.mvc.Controllers;

namespace mscook.mvc.Core
{
    public class ActionBonusFilter : ActionFilterAttribute
    {

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            string actionName = filterContext.ActionDescriptor.ActionName;

            var thisController = ((BaseController)filterContext.Controller);
            
            if (thisController.CurrentUser != null)
            {
                ActionBonusStrategy actionBonusStrategy = new ActionBonusStrategy(actionName, thisController.ActionBonusSettings, thisController.CurrentUser, thisController.LoginUserService);
                actionBonusStrategy.SetBonus();
            }
        }


    }
}